'use strict';
const express = require('express');
const model = require('../../../db/model');
const router = express.Router();

router.get('/:id', function(req, res) {
	const id = req.params.id || '';
	const sql = `
		select room_state.id,has_card,room_temp,speed,clean,dnd,ask,'leave',roomId,room_name,room_num,floor,'mode' from room_state,room_info 
		where room_state.roomId=${id} and room_info.id=${id};
	`;
	model
		.query(sql)
		.then(result => {
			console.log(result[0][0]);
			res.locals.data = result[0][0] || {};
			res.render('home');
		})
});

module.exports = router;